#include "dominion.h"
#include "dominion_helpers.h"
#include "rngs.h"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// This test checks fullDeckCount().

int main()
{
	int k[10] = {adventurer, gardens, embargo, village, minion, mine, cutpurse, sea_hag, tribute, smithy};
	struct gameState G;
	int randomSeed;
	int numPlayer = 2;
	int r, m, i, j;
	int numtests = 5;
	int ccount;
	
	srand(time(NULL));
	randomSeed = (rand() % 10)+1;
	m = initializeGame(numPlayer, k, randomSeed, &G);
	
	// Checks a deck size of 0.
	
	G.deckCount[0] = 0;
	G.handCount[0] = 0;
	G.discardCount[0] = 0;
	r = fullDeckCount(0, 1, &G);
	printf("Expected size: 0. Returned size: %i. ", r);
	if(r == 0)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
		
	// Checks an entire deck of 150 coppers.
	G.deckCount[0] = 50;
	G.handCount[0] = 50;
	G.discardCount[0] = 50;
	for(i=0;i<50;i++)
	{
		G.deck[0][i] = 4;
		G.hand[0][i] = 4;
		G.discard[0][i] = 4;
	}
	r = fullDeckCount(0,4,&G);
	printf("Expected copper count: 150. Returned: %i. ", r);
	if(r == 150)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
		
	// Checks a random set of cards numtests times for copper.
	for(i=0;i<numtests;i++)
	{
		ccount = 0;
		G.deckCount[0] = rand() % 50;
		G.handCount[0] = rand() % 50;
		G.discardCount[0] = rand() % 50;
		for(j=0;j<G.deckCount[0];j++)
		{
			G.deck[0][j] = (rand() % 3) + 4;
			if(G.deck[0][j] = 4)
				ccount++;
		}
		for(j=0;j<G.handCount[0];j++)
		{
			G.hand[0][j] = (rand() % 3) + 4;
			if(G.hand[0][j] = 4)
				ccount++;
		}
		for(j=0;j<G.discardCount[0];j++)
		{
			G.discard[0][j] = (rand() % 3) + 4;
			if(G.discard[0][j] = 4)
				ccount++;
		}
	r = fullDeckCount(0, 4, &G);
	printf("Expected %i copper on random deck. Returned %i copper. ", ccount, r);
	if(ccount == r)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
	
	}
	
		
	return 0;
	
}